package com.heima.user.controller.v1;

import com.aliyuncs.exceptions.ClientException;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AppLoginDTO;
import com.heima.model.user.dtos.LoginDTO;
import com.heima.user.service.AppLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "app端用户验证码登录",tags = "app端用户验证码登录")
@RestController
@RequestMapping("/api/v1/login")
public class AppLoginController {

    @Autowired
    AppLoginService appLoginService;


    @ApiOperation("发送验证码")
    @PostMapping("/sendCode")
    public ResponseResult sendCode(@RequestParam("phone") String phone) throws ClientException {
        return appLoginService.sendCode(phone);
    }

    @ApiOperation("登录")
    @PostMapping("/loginByCode")
    public ResponseResult login(@RequestBody AppLoginDTO dto) {
        return appLoginService.login(dto);
    }


}
